package com.sooth.micro.process.service;

import com.dream.boot.impl.ServiceImpl;
import com.sooth.micro.process.mapper.MicroProcessMapper;
import com.sooth.micro.process.view.MicroProcessBo;
import com.sooth.micro.process.view.MicroProcessVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@RequiredArgsConstructor
@Service
public class MicroProcessServiceImpl extends ServiceImpl<MicroProcessVo, MicroProcessBo> implements IMicroProcessService {
    private final MicroProcessMapper microProcessMapper;

    @Override
    public MicroProcessBo queryByAppId(Long appId) {
        return microProcessMapper.queryByAppId(appId);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int save(MicroProcessBo microProcess) {
        super.deleteById(microProcess.getProcessId());
        return super.insert(microProcess);
    }

    @Override
    public MicroProcessVo query(String processId) {
        return microProcessMapper.query(processId);
    }
}
